const { resolve } = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin")
module.exports = {
    entry: {
        'index':'./index.js'
    },
    target: 'electron-main',
    output: {
        filename:'[name].js',
        path: resolve(__dirname, 'build')
    },
    optimization: {
        minimizer: [
            `...`,
            new CssMinimizerPlugin(),
        ],
    },
    plugins: [
         new CopyWebpackPlugin({
            patterns: [
                {
                    from: resolve(__dirname, "package-prod.json"),
                    to: resolve(__dirname, "build/package.json")
                },
                {
                    from: resolve(__dirname, "src/"),
                    to: resolve(__dirname, "build/src/")
                }
            ],
        })
    ],
    // 生产环境下会自动压缩js代码
    mode: 'production'
};